package com.dhsc.service.impl.qsjk;

import java.io.File;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dhsc.constant.FtpFilePthContant;
import com.dhsc.domain.jkzx.qsjk.TQsjkrwVo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs04Vo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs05Vo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs06Vo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs07Vo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs08Vo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs09Vo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs10Vo;
import com.dhsc.domain.jkzx.qsjk.qsjkzx.Gs14Vo;
import com.dhsc.domain.yypt.common.DbfVo;
import com.dhsc.exception.MyException;
import com.dhsc.ftp.FTPUtil;
import com.dhsc.local.dao.qsjk.ITQsjkDao;
import com.dhsc.local.dao.qsjk.ITQsjkZxDao;
import com.dhsc.service.qsjk.ITQsjkZxService;
import com.dhsc.util.CommonUtil;
import com.dhsc.util.QsjkFilesUtil;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class TQsjkZxServiceImpl implements ITQsjkZxService{
	
	@Value("${bdpath}")
	private String bdpath;
	
	@Value("${ftp.path}")
	private String ftppath;
	
	@Autowired
	private ITQsjkDao qsjkDao;
	
	private static String gang = "/";

	@Autowired
	private ITQsjkZxDao qsjkZxDao;
	
	@Transactional("localTransactionManager")
	@Override
	public int gc01(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GC01";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GC01";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
    		if(!new File(filepath + "/BJZSMXSB.DBF.OK").exists()){
    			result = 2;
    			message.append("\n北京OK文件成功(异常)，");
    		}else{
    			message.append("\n北京OK文件成功，");
    			String filename = "BJZSMXSB.DBF";
        		if(!new File(filepath + gang + filename).exists()){
        			result = 2;
        			message.append("无文件");
        		}else{
        			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename);
        			if(CommonUtil.isNotEmptyObj(dbf) && dbf.getRecordCount() > 0)
        			{
        				int num = 0;
        				for(int i = 0;i < dbf.getRowList().size();i ++)
        				{
        					if("ZS".equals(String.valueOf(dbf.getRowList().get(i).get("SBYWLB"))))
        					{
        						num ++;
        					}
        				}
        				message.append("有" + num + "条记录；");
        			}else{
            			result = 2;
        				message.append("无记录；");
        			}
        		}
    		}
			
    		if(!new File(filepath + "/ZSMXSB.DBF.ok").exists()){
    			result = 2;
    			message.append("\n深圳OK文件成功(异常)，");
    		}else{
    			message.append("\n深圳OK文件成功，");
    			String filename = "ZSMXSB.DBF";
        		if(!new File(filepath + gang + filename).exists()){
        			result = 2;
        			message.append("无文件");
        		}else{
        			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename);
        			if(CommonUtil.isNotEmptyObj(dbf) && dbf.getRecordCount() > 0)
        			{
        				int num = 0;
        				for(int i = 0;i < dbf.getRowList().size();i ++)
        				{
        					if("ZS".equals(String.valueOf(dbf.getRowList().get(i).get("SBYWLB"))))
        					{
        						num ++;
        					}
        				}
        				message.append("有" + num + "条记录；");
        			}else{
            			result = 2;
        				message.append("无记录；");
        			}
        		}
    		}
			
    		File file = new File(filepath);
            File[] files = file.listFiles();
            
            int success = 0;
			int fail = 0;
            if (CommonUtil.isNotEmptyFile(files)) {
                for (File f : files) {
                    if (f.isFile()) {
                        String fileName = f.getName();
                        if(fileName.contains("Prop"))
                        {
                        	DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, fileName);
                			if(CommonUtil.isNotEmptyObj(dbf))
                			{
                				for(int i = 0;i < dbf.getRowList().size();i ++)
                				{
                					if("成功".equals(String.valueOf(dbf.getRowList().get(i).get("JGSM"))))
                					{
                						success ++;
                					}
                					if("失败".equals(String.valueOf(dbf.getRowList().get(i).get("JGSM"))))
                					{
                						fail ++;
                					}
                				}
                			}
                        }
                    }
                }
            }
            message.append("\n上海文件数量成功" + success + "条，失败" + fail + "条！");
            
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
				t.setLast_jgsm("【红利税文件申报成功！" + message.toString() + "】");
			}else{
				t.setLast_zxjg("4");
				t.setLast_jgsm("【红利税文件申报异常！" + message.toString() + "】");
			}
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	@Override
	public int gc02(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath1 = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "文件模版/GC02";
			String filepath1 = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/文件模版/GC02";
			FTPUtil.downloadFtpFiles(ftpPath1, filepath1);
			
			String ftpPath2 = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GC02";
			String filepath2 = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GC02";
			FTPUtil.downloadFtpFiles(ftpPath2, filepath2);
			
			String filenmc = "JJHQRQ";//文件名称
			String filenhz = ".LOG";//文件后缀
			
			if(!new File(filepath1 + gang + filenmc + filenhz).exists() &&  !new File(filepath2 + gang + filenmc + CommonUtil.getDateSystem() + filenhz).exists()){
    			result = 2;
    			message.append("模版文件不存在，文件不存在！");
    		}else{
    			if(new File(filepath1 + gang + filenmc + filenhz).exists() &&  !new File(filepath2 + gang + filenmc + CommonUtil.getDateSystem() + filenhz).exists()){
        			result = 2;
        			message.append("模版文件存在，文件不存在！");
        		}else{
        			String filename = "JJHQRQ" + CommonUtil.getDateSystem() + ".LOG";
        			
        			List<String> list = QsjkFilesUtil.readLogFile(filepath2, filename);
        			List<String> newlist = list;
        			
        			if(CommonUtil.isNotEmptyList(list))
        			{
        				for(int i = 0;i < list.size();i ++)
        				{
        					for(int j = newlist.size() - 1;j >= 0;j --)
        					{
        						if(QsjkFilesUtil.getSubstring(list.get(i), "[", "]").equals(QsjkFilesUtil.getSubstring(newlist.get(i), "[", "]")) 
        								&& QsjkFilesUtil.compareTime(list.get(i).substring(0, 8), newlist.get(i).substring(0, 8)))
        						{
        							newlist.remove(j);
        							break;
        						}
        					}
        				}
        			}
        			
        			int fail = 0;
        			StringBuilder failName = new StringBuilder();
        			
        			if(new File(filepath1 + "/JJHQRQ.LOG").exists()){
        				int many = 0;//多XX基金数量
            			StringBuilder manyName = new StringBuilder();//多XX基金名称

            			int few = 0;//少XX基金数量
            			StringBuilder fewName = new StringBuilder();//少XX基金名称
            			
            			List<String> listmb = QsjkFilesUtil.readLogFile(filepath1, "JJHQRQ.LOG");
            			if(CommonUtil.isNotEmptyList(listmb))
            			{
            				if(CommonUtil.isNotEmptyList(newlist))
            				{
            					for(int i = 0;i < listmb.size();i ++)
            					{
            						int num = 0;
            						for(int j = 0;j < newlist.size();j ++)
                					{
                						if(QsjkFilesUtil.getSubstring(listmb.get(i), "[", "]").equals(QsjkFilesUtil.getSubstring(newlist.get(j), "[", "]")))
                						{
                							num  = 1;
                						}
                					}
            						if(num == 0)
            						{
            							few ++;
            							result = 2;
            							if(CommonUtil.isNotEmptyBuilder(fewName))
            							{
            								fewName.append("、");
            							}
            							fewName.append(QsjkFilesUtil.getSubstring(listmb.get(i), "[", "]") + "基金");
            						}
            					}
            					for(int i = 0;i < newlist.size();i ++)
            					{
            						int num = 0;
            						for(int j = 0;j < listmb.size();j ++)
                					{
                						if(QsjkFilesUtil.getSubstring(newlist.get(i), "[", "]").equals(QsjkFilesUtil.getSubstring(listmb.get(j), "[", "]")))
                						{
                							num  = 1;
                						}
                					}
            						if(num == 0)
            						{
            							many ++;
            							result = 2;
            							if(CommonUtil.isNotEmptyBuilder(manyName))
            							{
            								manyName.append("、");
            							}
            							manyName.append(QsjkFilesUtil.getSubstring(newlist.get(i), "[", "]") + "基金");
            						}
            					}
            					if(few == 0 && many == 0)
            					{
            						message.append("少" + few + "个基金公司文件;多" + many + "个基金公司文件;");
            					}else if(few > 0 && many == 0)
            					{
            						message.append("少" + few + "个基金公司文件,[" + fewName.toString() + "];多" + many + "个基金公司文件;");
            					}else if(few == 0 && many > 0)
            					{
            						message.append("少" + few + "个基金公司文件;多" + many + "个基金公司文件,[" + manyName.toString() + "];");
            					}else{
            						message.append("少" + few + "个基金公司文件,[" + fewName.toString() + "];多" + many + "个基金公司文件,[" + manyName.toString() + "];");
            					}
            					
            				}else{
            					result = 2;
                				message.append("文件内容为空；");
            				}
            			}else{
            				result = 2;
            				message.append("模版文件内容为空；");
            			}
            		}else{
            			result = 2;
            			message.append("模版文件不存在，");
            		}
        			
        			if(CommonUtil.isNotEmptyList(newlist))
        			{
    					for(int i = 0;i < newlist.size();i ++)
        				{
        					if(!newlist.get(i).contains("导入行情信息数据成功"))
        					{
        						fail ++;
        						if(CommonUtil.isNotEmptyBuilder(failName))
        						{
        							failName.append("、");
        						}
        						failName.append(QsjkFilesUtil.getSubstring(newlist.get(i), "[", "]") + "基金");
        					}
        				}
    					if(fail == 0)
    					{
    						message.append(fail + "个基金公司导入失败");
    					}else{
    						message.append(fail + "个基金公司导入失败，（" + failName.toString() + "）");
    					}
        			}else{
        				result = 2;
        				message.append("文件内容为空；");
        			}
        		}
    		}
			
			long endtime = System.currentTimeMillis();
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
				t.setLast_jgsm("【" + message.toString() + "】");
			}else{
				t.setLast_zxjg("4");
				t.setLast_jgsm("【" + message.toString() + "】");
			}
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
			
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	@Override
	public int gc03(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GC03";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GC03";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename1 = CommonUtil.getDateSystem() + "CHECK06_FH.DBF";
			if(!new File(filepath + gang + filename1).exists()){
    			result = 2;
    			message.append("CHECK06_FH文件不存在");
    		}else{
    			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename1);
    			if(CommonUtil.isNotEmptyObj(dbf) && dbf.getRecordCount() > 0)
    			{
    				int fail = 0;
    				for(int i = 0;i < dbf.getRowList().size();i ++)
    				{
    					if(!"处理成功".equals(String.valueOf(dbf.getRowList().get(i).get("JGSM"))))
    					{
    						fail ++;
    					}
    				}
    				message.append("总记录数" + dbf.getRecordCount() + "条，失败" + fail + "条");
    			}else{
        			result = 2;
    				message.append("文件无数据");
    			}
    		}
			
			String filename2 = CommonUtil.getDateSystem() + "CHECK06_DZ3.DBF";
			if(new File(filepath + gang + filename2).exists()){
    			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename2);
    			if(CommonUtil.isNotEmptyObj(dbf) && dbf.getRecordCount() > 0)
    			{
    				result = 2;
    				message.append(";当日存在东海通宝对账异常" + dbf.getRecordCount() + "条");
    			}
    		}
            
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	@Override
	public int gc04(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GC04";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GC04";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename = "abnorconfirm_" + CommonUtil.getDateSystem() + ".TXT";
			if(!new File(filepath +gang+ filename).exists()){
    			result = 2;
    			message.append("abnorconfirm文件不存在！");
    		}else{
				List<String> list = QsjkFilesUtil.readLogFile(filepath, filename);
				if(CommonUtil.isNotEmptyList(list))
				{
					if (list.size() >= 2 && "0".equals(list.get(0)) && "END".equals(list.get(1))){
						message.append("当日现金宝异常数据0条。");
					} else {
						result = 2;
						message.append("当日存在现金宝异常数据" + list.get(0) + "条！\n请晨间业务经办人员协同金融科技部完成异常处理后，人工修改本条监控状态。");
					}
				}else{
					result = 2;
					message.append("当日现金宝异常文件无数据，请联系自TA人员处理。");
				}
    		}

			long endtime = System.currentTimeMillis();
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
				t.setLast_jgsm("【" + message.toString() + "】");
			}else{
				t.setLast_zxjg("4");
				t.setLast_jgsm("【" + message.toString() + "】");
			}
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	@Override
	public int gc07(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GC07";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GC07";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
            String fullDate=CommonUtil.getDateSystem();
			String sMonth=fullDate.substring(4,6);
			String sDay=fullDate.substring(6);
			if ("10".equals(sMonth)){
				sMonth="a";
			} else if ("11".equals(sMonth)) {
				sMonth = "b";
			} else if ("12".equals(sMonth)) {
				sMonth = "c";
			}else {
				sMonth = sMonth.substring(1);
			}
			String shortDate=sMonth+sDay;
			String filename1="wbsggtqx_100024."+shortDate;
			if(!new File(filepath + gang + filename1).exists()){
    			result = 2;
    			message.append("当日wbsggtqx文件不存在，请检查！");
    		}else{
    			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename1);
    			if(CommonUtil.isNotEmptyObj(dbf))
    			{
					if (dbf.getRecordCount()==0){
						message.append("当日无未报送港股通权限数据。");
					}else{
        				result = 2;
        				message.append("当日存在未报送港股通权限数据"+dbf.getRecordCount()+"条，内容如下：\n"+dbf.getRowList().toString());
					}
        		}else{
        			result = 2;
    				message.append("当日wbsggtqx文件格式异常，请检查！");
    			}
    		}
			
			long endtime = System.currentTimeMillis();
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	@Override
	public int gcw01(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GCW01";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GCW01";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename="NQHGTZZJC500210.DBF";
			String rq=CommonUtil.getDateSystem();
			
			if(!new File(filepath + gang + filename).exists()){
    			result = 2;
    			message.append("当日股转投资者报送反馈文件（NQHGTZZJC500210.DBF）不存在，请检查！");
    		}else{
    			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename);
    			if(CommonUtil.isNotEmptyObj(dbf))
    			{
    				int sl=dbf.getRecordCount()-1;
    				if(sl<1){
    					result = 2;
    					message.append("当日股转投资者报送反馈文件（NQHGTZZJC500210.DBF）格式异常，请检查！");
    				} else {
    					if(!rq.equals(dbf.getRowList().get(1).get("HGSQRQ"))){
    						result = 2;
    						message.append("当日股转投资者报送反馈文件（NQHGTZZJC500210.DBF）日期异常，请检查！");
    					} else {
    						for(int i=1;i<=sl;i++){
    							String jg = dbf.getRowList().get(i).get("HGJCJG");
    							if (!"00".equals(jg)){
    								result = 2;
    								message.append("当日股转投资者报送反馈文件（NQHGTZZJC500210.DBF）存在异常记录，请检查！");
    								break;
    							}
    						}
    					}
    				}
    				if (result == 1){
    					message.append("当日股转投资者数据报送成功，报送数量："+sl+"条。");
    				}
        		}else{
        			result = 2;
    				message.append("当日股转投资者报送反馈文件（NQHGTZZJC500210.DBF）格式异常，请检查！");
    			}
    		}
			
			
			long endtime = System.currentTimeMillis();
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	@Override
	public int gcw02(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GCW02";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GCW02";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename = "pfxsys" + CommonUtil.getDateSystem() + ".log";
			String flagtxt="Sending-Success:C:\\prop2000\\pfxdata\\CSDCC\\send\\gjtzh_100024_"+CommonUtil.getDateSystem()+".txt(sendmodule.cpp 1037)";
			if(!new File(filepath +gang+ filename).exists()){
    			result = 2;
    			message.append("港股通数据报送pfx日志文件不存在！");
    		}else{
				List<String> list = QsjkFilesUtil.readLogFile(filepath, filename);
				if(CommonUtil.isNotEmptyList(list))
				{
					result = 2;
					for (String x : list){
						if (x.indexOf(flagtxt)>=0){
							result = 1;
							message.append("港股通数据报送成功！");
							break;
						}
					}
					if (result == 2) {
						message.append("港股通数据未报送，请检查！");
					}
				}else{
					result = 2;
					message.append("港股通数据报送pfx日志文件无数据，请检查！");
				}
    		}

			long endtime = System.currentTimeMillis();
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
				t.setLast_jgsm("【" + message.toString() + "】");
			}else{
				t.setLast_zxjg("4");
				t.setLast_jgsm("【" + message.toString() + "】");
			}
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	@Override
	public int gcXY01(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GCXY01";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GCXY01";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename1 = "yhdz.DBF";
			if(!new File(filepath + gang + filename1).exists()){
    			result = 2;
    			message.append("yhdz文件不存在");
    		}else{
    			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename1);
    			if(CommonUtil.isNotEmptyObj(dbf) && dbf.getRecordCount() > 0)
    			{
    				int fail = 0;
    				for(int i = 0;i < dbf.getRowList().size();i ++)
    				{
    					if(!"0.00".equals(String.valueOf(dbf.getRowList().get(i).get("CY"))))
    					{
    						fail ++;
    					}
    				}
    				
    				message.append("总记录数" + dbf.getRecordCount() + "条，失败" + fail + "条");
    			}else{
        			result = 2;
    				message.append("文件无数据");
    			}
    		}
			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	public int gc05(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GC05";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GC05";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename1 = "xzcy.dbf";
			if(!new File(filepath + gang + filename1).exists()){
    			result = 2;
    			message.append("当日新增差异文件不存在，请检查！");
    		}else{
    			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename1);
    			if(CommonUtil.isNotEmptyObj(dbf) && dbf.getRecordCount() > 0)
    			{
        			result = 2;
        			message.append("当日股份对账存在新增异常" + dbf.getRecordCount() + "条");
        		}else{
        			result = 1;
    				message.append("当日对账文件无新增异常数据");
    			}
    		}
			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	public int Gs02(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GS02";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GS02";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename1 = "10080000_" + CommonUtil.getDateSystem() + "_SUCCESS.txt";
			String filename2 = "GPZY_10080000_" + CommonUtil.getDateSystem() + "_SUCCESS.txt";

			if(new File(filepath + gang + filename1).exists() && new File(filepath + gang + filename2).exists()){
    			result = 1;
    			message.append("当日证金报送数据、股票质押报送数据已成功！");
    		}else{
    			result = 2;
    			if(new File(filepath + gang + filename1).exists() && !new File(filepath + gang + filename2).exists()){
        			message.append("当日股票质押报送数据不成功，请检查！");
        		}
    			if(!new File(filepath + gang + filename1).exists() && new File(filepath + gang + filename2).exists()){
        			message.append("当日证金报送数据不成功，请检查！");
            	}
    			if(!new File(filepath + gang + filename1).exists() && !new File(filepath + gang + filename2).exists()){
        			message.append("当日证金报送数据、股票质押报送数据不成功，请检查！");	
        		}
        	}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	public int Gs03(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GS03";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GS03";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename1 = "pfxsnd" + CommonUtil.getDateSystem() + ".log";

			if(!new File(filepath + gang + filename1).exists()){
    			result = 2;
    			message.append("当日投保报送日志文件不存在，请检查！");
    		}else{
    			result = 2;
    			List<String> list = QsjkFilesUtil.readLogFile(filepath, filename1);
    			if(CommonUtil.isNotEmptyList(list))
    			{
    				if(list.size() >= 21)
    				{
    					int resulta = 0;//0失败   1：成功
        				for(int i = 0;i < list.size();i ++)
        				{
        					String []arr = list.get(i).split("|");
        					if("CSDCC".equals(arr[0])){
        						resulta = 1;
                			}
        				}

    					int resultb = 1;//0失败   1：成功
        				String []nums = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19"};
        				for(int j = 0;j < nums.length;j ++)
    					{
        					int num = 0;
        					for(int i = 0;i < list.size();i ++)
            				{
        						String []arr = list.get(i).split("|");
            					if(("SC_10080000_" + CommonUtil.getDateSystem() +"_001N_A" + nums[j] + "_Z_YA.7Z").equals(arr[2]))
        						{
        							num = 1;
        						}
            				}
        					if(num == 0)
        					{
        						resultb = 0;
        						break;
        					}
    					}
        				if(resulta == 1 &&  resultb == 1)
        				{
                			message.append("当日投保报送日志文件内容正常！");
        				}else{
        					result = 2;
                			message.append("当日投保报送日志文件内容异常，请检查！");
        				}
    				}else{
    					result = 2;
            			message.append("当日投保报送日志文件内容异常，请检查！");
    				}
    			}else{
    				result = 2;
        			message.append("当日投保报送日志文件内容为空，请检查！");
    			}
        	}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Override
	public int gs04(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			List<Gs04Vo> list = qsjkZxDao.gs04();
			if(CommonUtil.isNotEmptyList(list))
			{
				result = 2;
				message.append("可用资金不足，详情如下：");
				for(int i = 0;i < list.size();i ++)
				{
					if(CommonUtil.isNotEmptyBuilder(message))
					{
						message.append("\n");
					}
	    			message.append((i + 1) + "、客户号：" + list.get(i).getKhh() + ";资金账户：" + list.get(i).getZjzh() 
	    					+ ";透支金额：" + list.get(i).getTzje());
				}
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}	

	public int gs05(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			List<Gs05Vo> list = qsjkZxDao.gs05();
			if(CommonUtil.isNotEmptyList(list))
			{
				result = 2;
				message.append("发生冻结资金超期异常，详情如下：");
				for(int i = 0;i < list.size();i ++)
				{
					if(CommonUtil.isNotEmptyBuilder(message))
					{
						message.append("\n");
					}
	    			message.append((i + 1) + "、客户号：" + list.get(i).getKhh() + ";资金账户：" + list.get(i).getZjzh() 
	    					+ "于" + list.get(i).getFsrq() + "发生冻结资金" + list.get(i).getDjje() +";冻结原因为：" +list.get(i).getZy());
				}
			}else{
				result = 1;
				message.append("当日无资金冻结超期记录数据！");
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}	

	public int gs06(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			List<Gs06Vo> list = qsjkZxDao.gs06();
			if(CommonUtil.isNotEmptyList(list))
			{
				result = 2;
				message.append("上日发生司法扣划资金红冲业务，详情如下：");
				for(int i = 0;i < list.size();i ++)
				{
					if(CommonUtil.isNotEmptyBuilder(message))
					{
						message.append("\n");
					}
	    			message.append((i + 1) + "客户：" + list.get(i).getKhxm() + ";客户号：" + list.get(i).getKhh() 
	    					+ "于" + list.get(i).getJsrq() + "发生红冲资金" + list.get(i).getFcje() +"。");
				}
			}else{
				result = 1;
				message.append("当日无资金冻结超期记录数据！");
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}	

	public int gs07(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			Gs07Vo gs07vo = qsjkZxDao.gs07();
			if(CommonUtil.getDateSystem().equals(gs07vo.getRrxfksr())){
				result = 2;
				message.append("今天是" + CommonUtil.getDateSystem() + ",今天需进行融资融券息费扣收操作，请注意！");
			}else{
				message.append("当日非融资融券息费扣收日。");
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}	

	public int gs08(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			Gs08Vo gs08vo = qsjkZxDao.gs08();
			if(gs08vo.getJdjxr().equals(CommonUtil.getDateSystem())){
				result = 2;
				message.append("今天是" + CommonUtil.getDateSystem() + ",需进行季度结息操作，请注意！");
			}else{
				message.append("当日非季度结息日。");
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}	
	
	public int gs09(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			List<Gs09Vo> list = qsjkZxDao.gs09();
				
			if(CommonUtil.isNotEmptyList(list))
			{
				result = 2;
				int fail = 0;
				for(int i = 0;i < list.size();i ++)
				{
					if(!"2".equals(list.get(i).getSbjg()))
					{
						fail ++;
					}
				}
				if(fail == 0){
				result =1;
				message.append("当日存在现金管家委托记录：" + list.size() + "条。");
				}else{
					result =2;
					message.append("当日存在现金管家委托失败记录：" + fail + "条，请检查！");
					}
			}else{
				result = 2;
				message.append("未检测到现金管家委托数据，请确认！");
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}	

	public int gs10(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			List<Gs10Vo> list = qsjkZxDao.gs10();
				
			if(CommonUtil.isNotEmptyList(list))
			{
				result = 2;
				int fail = 0;
				for(int i = 0;i < list.size();i ++)
				{
					if(!"6".equals(list.get(i).getSbjg()))
					{
						fail ++;
					}
				}
				if(fail == 0){
				result =1;
				message.append("当日存在东海通宝委托记录：" + list.size() + "条。");
				}else{
					result =2;
					message.append("当日东海通宝存在委托失败记录：" + fail + "条，请检查！");
					}
			}else{
				result = 2;
				message.append("未检测到东海通委托数据，请确认！");
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}
	
	@Transactional("localTransactionManager")
	@Override
	public int gs11(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GS11";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GS11";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filename1 = "PLKHSXBG.DBF_" + CommonUtil.getDateSystem() + ".DBF";
			if(!new File(filepath + "/" + filename1).exists()){
    			result = 2;
    			message.append( CommonUtil.getDateSystem() + "当日融资融券授信变更文件不存在，请检查！");
    		}else{
    			DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath, filename1);
    			if(CommonUtil.isNotEmptyObj(dbf) && dbf.getRecordCount() > 0)
    			{
    				int fail = 0;
    				int success1=0;
    				int success2=0;
    				for(int i = 0;i < dbf.getRowList().size();i ++)
    				{
    					if(String.valueOf(dbf.getRowList().get(i).get("处理结果")).indexOf("失败")!= -1)
    					{
    						fail ++;
    					}
    					if(String.valueOf(dbf.getRowList().get(i).get("处理结果")).contains("无需变更"))
    					{
    						success1 ++;
    					}
    					if("处理成功".equals(String.valueOf(dbf.getRowList().get(i).get("处理结果"))))
    					{
    						success2 ++;
    					}
    				}
    				if(fail == 0)
    				{
    					result = 1;
    					message.append("当日融资融券授信变更无失败记录，其中处理成功" + success2 + "条，无需处理" + success1 + "条。");
    				}else{
    					result = 2;
    					message.append("当日融资融券授信变更存在失败记录：" + fail + "条，请检查");
    				}    				
    			}else{
        			result = 2;
    				message.append("当日融资融券授信变更文件无数据，请检查！");
    			}
    		}
			           
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}
	
	@Transactional("localTransactionManager")
	public int gs12(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GS12";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GS12";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			String filenamewy = "WY_" + CommonUtil.getDateSystem() + "_39148600";
			String filenamexy = "XY_" + CommonUtil.getDateSystem() + "_39148600";
			
			if(new File(filepath + "/" + filenamewy + ".suc").exists() && new File(filepath + "/" + filenamexy + ".suc").exists()){
    			result = 1;
    			message.append("当日深圳市场融资融券数据已报送通过！");
    		}else{
    			result = 2;
    			if(!new File(filepath + "/" + filenamewy + ".suc").exists() && !new File(filepath + "/" + filenamexy + ".suc").exists() && 
    					!new File(filepath + "/" + filenamewy + ".err").exists() && !new File(filepath + "/" + filenamexy + ".err").exists()){
        			message.append("未检测到当日深圳市场融资融券数据，请检查！");
        		}
    			if(!new File(filepath + "/" + filenamewy + ".suc").exists() && !new File(filepath + "/" + filenamexy + ".suc").exists() &&
    					new File(filepath + "/" + filenamewy + ".err").exists() && new File(filepath + "/" + filenamexy + ".err").exists()){
        			message.append("检测到当日深圳市场融资融券数据检查未通过，请检查！");
            	}
        	}
			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	@Transactional("localTransactionManager")
	public int gs13(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			
			String ftpPath = ftppath + CommonUtil.getDateSystem() + FtpFilePthContant.FTP_JKZX_QSJK + "GS13";
			String filepath = bdpath + FtpFilePthContant.JKZX_QSJK + CommonUtil.getDateSystem() + "/GS13";
			FTPUtil.downloadFtpFiles(ftpPath, filepath);
			
			int resulta = 0;//0失败   1：成功
			int resultb = 0;//0失败   1：成功
			if(new File(filepath + "/" + "WYJC500210.DBF").exists()){
				DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath , "WYJC500210.DBF");	
				String wyjg = String.valueOf(dbf.getRowList().get(0).get("WYJCJG"));
				if("00".equals(wyjg)){
					resulta = 1;
					message.append("北京融资融无违约数据；");	
    				}else{
    					result = 2;
    					message.append("北京融资融存在违约数据" + wyjg + "条；");
    			}
    		}else{
    			result = 2;
    			message.append("未检测到当日北京融资融券违约数据,请检查!"); 			
    		}
			
			if(new File(filepath + "/" + "RRJC500210.DBF").exists()){
				DbfVo dbf = QsjkFilesUtil.readDbfFile(filepath , "RRJC500210.DBF");	
				String rrjg = String.valueOf(dbf.getRowList().get(0).get("RRCWXX"));
				if("00".equals(rrjg)){
					resultb = 1;
					message.append("北京融资融无余额异常数据。");	
    				}else{
    					result = 2;
    					message.append("北京融资融存在额异常数据" + rrjg + "条；请检查！");
    			}
    		}else{
    			message.append("/n未检测到当日北京融资融券余额数据,请检查!"); 			
    		}

    		if(resulta == 1 && resultb == 1){
    			result = 1;
    			message.append("当日北京融资融券违约、余额数据已检查通过。");
    		}
			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

	public int gs14(TQsjkrwVo t) {
		int result = 1;//  1:正常    2：异常
		StringBuilder message = new StringBuilder();
		try {
			String lastZxsj = CommonUtil.getDateTime();
			long starttime = System.currentTimeMillis();
			List<Gs14Vo> list = qsjkZxDao.gs14();
				
			if(CommonUtil.isNotEmptyList(list))
			{
				result = 2;
				for (int i = 0;i <list.size();i ++){				
					message.append("检测到当日存在退补款新增文件" + list.size() +"条！文件路径为" + list.get(i).getAbsolutepath() + "。");
				}
			}else{
				result = 1;
				message.append("未检测到当日存在新增退补款文件。");
			}
      			
			long endtime = System.currentTimeMillis();
			
			t.setLast_zxhs(String.valueOf((endtime - starttime)/1000));
			if(result == 1)
			{
				t.setLast_zxjg("2");
			}else{
				t.setLast_zxjg("4");
			}
			t.setLast_jgsm("【" + message.toString() + "】");
			t.setLast_zxsj(lastZxsj);
			qsjkDao.insertTQsjkrwLs(t);
			qsjkDao.updateTQsjkrwLastLs(t);
		} catch (Exception e) {
			log.error("执行【" + t.getRwmc() + "失败】",e);
			throw new MyException("执行【" + t.getRwmc() + "失败】",e);
		}
		return result;
	}

}
